using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace AvalonAdmin.ViewModels
{
    public partial class AboutViewModel : ObservableObject
    {
        public ICommand NavigateCommand { get; set; }

        internal ILauncher? Launcher { get; set; }

        public AboutViewModel()
        {
            NavigateCommand = new AsyncRelayCommand<string>(OnNavigateAsync);
        }

        private static readonly IReadOnlyDictionary<string, string> _keyToUrlMapping = new Dictionary<string, string>()
        {
            ["carSource"] = "https://www.baidu.com",
            ["rule"] = "https://www.baidu.com",
            ["analysis"] = "https://www.baidu.com",
            ["automatic"] = "https://www.baidu.com",
        };

        private async Task OnNavigateAsync(string? arg)
        {
            if (Launcher is not null && arg is not null && _keyToUrlMapping.TryGetValue(arg.ToLower(), out var uri))
            {
                await Launcher.LaunchUriAsync(new Uri(uri));
            }

        }
    }
}

